#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[1000];

signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	sort(a + 1, a + n + 1);
	int ans = a[n] * a[n], pre = n;
	for (int i = 1; i < n; i++) {	// 易知必跳n-1次
		int t = n - pre;
		t = t > pre ? t : t + 1;
		ans += (a[pre] - a[t]) * (a[pre] - a[t]);
		pre = t;
	}
	cout << ans;
	return 0;
}
